<template>
	<view class="page">
		<view class="group_2">
			<view class="" style="width: 100%;height: 1rpx;background-color: #dedede;"></view>
			<view class="group_3">

				<view class="item">
					<view class="item-title">所选卡</view>
					<view class="flex-space-between">
						<text>篮球十次卡</text>
						<text style="font-size: 28rpx;font-weight: bold;color: #FF4105;">￥488</text>
					</view>
				</view>
				<!-- <text lines="1" class="text_8">开卡方式</text> -->
				<view class="text_7">记账类型</view>
				<view class="item" style="border-bottom: solid 2rpx #efefef;">
					<view class="flex-space-between week-list">
						<input type="text" placeholder="请选择" disabled v-model="ordersList.card_relation" disabled  @click="showcard = true">
					</view>
				</view>
				<view class="item">
					<view class="item-title">记账金额</view>
					<view class="flex-space-between">
						<input class="value" placeholder="请输入" v-model="formData.classItem" />
					</view>
				</view>

				<text lines="1" class="text_7">记账凭证</text>
				<view class="" style="margin-top: 40rpx;margin-left: 20rpx;border-bottom: solid 2rpx #efefef;">
					<u-upload  :fileList="fileList1" name="1" width="150rpx" height="150rpx" @afterRead="afterRead"
						@delete="deletePic" multiple :maxCount="3" />
				</view>
				<view class="item">
					<view class="item-title">备注</view>
					<view class="flex-space-between">
						<input class="value" placeholder="请输入" v-model="formData.classItem" />
					</view>
				</view>
				<!-- <text lines="1" class="text_8">发送渠道</text>
				<view class="item">
					<view class="flex-space-between week-list">
						<view class="week-item" :class="{'active':weekSelect.includes(item)}" v-for="item in weekList"
							:key="item" @click="handSelect(item)">
							{{item.name}}
						</view>
					</view>
				</view> -->
			</view>
			<button bindtap="onClick" class="button_3">
				确认
			</button>
		</view>
		<!-- 选择卡 -->
		<u-picker :show="showcard" :columns="card_status" keyName="label"
			@confirm="card_list" @cancel="showcard = false">
		</u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList1: [],
				url_phone: '',
				weekList: [{name:'短信',id:'1'}, {name:'站内信',id:'2'}],
				weekSelect: [], //选中的
				ordersList: {},
				showcard:false,
				card_status: [], //操作员
			}
		},
		onLoad() {
			this.cardlist()
		},
		methods: {
			// 选择卡
			card_list(e) {
				this.ordersList.card_relation = e.value[0].label
				this.ordersList.card_relation_id = e.value[0].id
				this.showcard = false
			},
			// 开卡方式
			async cardlist() {
				let card_list = [
					{
						id: 1,
						label: "立即开卡"
					},
					{
						id: 2,
						label: "暂不开卡"
					}
				]
				this.card_status.push(
					card_list
				)
				// let params = {
				// 	app_id: this.$https.weixinAppId,
				// 	project_id: getApp().globalData.projectId,
				// }
				// let res = await train.conf(params);
				// if (res.code == 1) {
					
				// 	this.card_status.push(
				// 		res.data.list.card_list
				// 	)
				// }
			},
			xzclick(){
				uni.navigateTo({
					url: '/page_member/marketing_jifts/gift_giving'
				})
			},
			handSelect(data) {
				if (this.weekSelect.includes(data)) {
					this.weekSelect = this.weekSelect.filter((item) => {
						return item !== data
					})
				} else {
					this.weekSelect.push(data)
				}
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: this.url_phone
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'https://sass-test.doit10019.com/api/upload/uploadOneImage', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							// user: 'test',
							project_id: getApp().globalData.projectId,
							app_id: this.$https.weixinAppId,

						},
						success: (res) => {
							let result = JSON.parse(res.data);
							this.url_phone = result.data.url
							setTimeout(() => {
								resolve(this.url_phone)
							}, 1000)
						}
					});
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		width: 100%;
		height: 100vh;
		background-color: #dedede;

		.group_3 {
			background-color: rgba(255, 255, 255, 1.000000);
			width: 710rpx;
			height: 938rpx;
			display: flex;
			flex-direction: column;
			margin: 20rpx 0 0 20rpx;

			.item {
				padding: 29rpx 30rpx 30rpx;

				.item-title {
					color: rgb(153, 153, 153);
					font-size: 28rpx;
					font-weight: 500;
					margin-bottom: 20rpx;
				}

				.value {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
				}

				.time-cell {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
					justify-content: flex-start;

					.time {
						width: 49%;

						&:last-of-type {
							margin-left: 20rpx;
						}
					}
				}

				.week-list {
					display: grid;
					grid-template-columns: repeat(5, 1fr);
					grid-gap: 20rpx;
					position: relative;

					.week-item {
						padding: 15rpx 0;
						background-color: rgb(243, 243, 243);
						border-radius: 5rpx;
						text-align: center;
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						font-weight: 500;
						border: solid 2rpx transparent;
						box-sizing: border-box;
					}

					.active {
						color: rgba(255,98,0,1);
						background-color: rgba(255,65,5,0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;

						// &:before {
						// 	display: block;
						// 	content: '';
						// 	position: absolute;
						// 	width: 27rpx;
						// 	height: 28rpx;
						// 	right: -2rpx;
						// 	bottom: -2rpx;
						// 	background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/46b1cc85fcb0fd76095daf823b7d2bb4a3235519.png");
						// 	background-repeat: no-repeat;
						// 	background-size: 100%;
						// }
					}

					.check {
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						position: absolute;
						bottom: 10rpx;
						right: 0;
					}
				}
			}
		}

		.text_2 {
			width: 93rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 40rpx 0 0 21rpx;
		}

		.section_1 {
			width: 90%;
			height: 40rpx;
			flex-direction: row;
			display: flex;
			justify-content: space-between;
			margin: 28rpx 0 0 20rpx;
		}

		.box_3 {
			height: 40rpx;
			background-size: 100% 100%;
			display: flex;
			flex-direction: row;
			// width: 150rpx;
		}

		.label_1 {
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
		}

		.label_2 {
			width: 40rpx;
			height: 40rpx;
			margin-left: -6rpx;
			border-radius: 50%;
		}

		.label_3 {
			width: 40rpx;
			height: 40rpx;
			margin-left: -6rpx;
			border-radius: 50%;
		}

		.image-text_1 {
			width: 150rpx;
			height: 27rpx;
			margin-top: 6rpx;
			flex-direction: row;
			display: flex;
			justify-content: space-between;
		}

		.text-group_1 {
			width: 126rpx;
			height: 27rpx;
			overflow-wrap: break-word;
			color: rgba(40, 40, 40, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
		}

		.icon_2 {
			width: 7rpx;
			height: 14rpx;
			margin-top: 13rpx;
		}

		.section_2 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_3 {
			width: 47rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 42rpx 0 0 19rpx;
		}

		.text_4 {
			width: 82rpx;
			height: 26rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 24rpx 0 0 20rpx;
		}

		.section_3 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_5 {
			width: 47rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 39rpx 0 0 19rpx;
		}

		.text_6 {
			width: 82rpx;
			height: 26rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 24rpx 0 0 20rpx;
		}

		.section_4 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_7 {
			width: 95rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 39rpx 0 0 19rpx;
		}

		.image_2 {
			width: 151rpx;
			height: 151rpx;
			margin: 25rpx 0 0 18rpx;
		}


		.text_8 {
			width: 95rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 40rpx 0 0 19rpx;
		}

		.section_6 {
			width: 378rpx;
			height: 62rpx;
			flex-direction: row;
			display: flex;
			justify-content: space-between;
			margin: 26rpx 0 27rpx 21rpx;
		}

		.button_1 {
			background-color: rgba(243, 243, 243, 1.000000);
			height: 62rpx;
			display: flex;
			flex-direction: column;
			width: 174rpx;
		}

		.text_9 {
			width: 48rpx;
			height: 24rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 19rpx 0 0 63rpx;
		}

		.button_2 {
			background-color: rgba(255, 65, 5, 0.100000);
			height: 62rpx;
			display: flex;
			flex-direction: column;
			width: 174rpx;
		}

		.text_10 {
			width: 73rpx;
			height: 24rpx;
			overflow-wrap: break-word;
			color: rgba(255, 98, 0, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 19rpx 0 0 51rpx;
		}
		.button_3{
			width: 90%;
			height: 80rpx;
			position: absolute;
			bottom: 20rpx;
			background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255,64,64,0.93), rgba(250,142,142,0.93));
			border-radius: 80rpx 80rpx;
			margin-left: 5%;
			color: rgba(255,255,255,1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
		}
	}
</style>